{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b201e611",
   "metadata": {},
   "source": [
    "#  输出函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e8574b8a",
   "metadata": {},
   "source": [
    "## print()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8d83d2ee",
   "metadata": {},
   "source": [
    "----\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1d60b6d1",
   "metadata": {},
   "source": [
    " ## 转义字符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5e65487f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world\n"
     ]
    }
   ],
   "source": [
    "print(\"hello world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "76b2c4bc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\n",
      "world\n"
     ]
    }
   ],
   "source": [
    "print('hello\\nworld')# \\n n→newline首字母，表示换行 具有转义功能"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a75e1584",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\tworld\n"
     ]
    }
   ],
   "source": [
    "print('hello\\tworld')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "248fe216",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "helloooo\tworld\n"
     ]
    }
   ],
   "source": [
    "print('helloooo\\tworld')# \\t 水平制表符 四格一单位的格式中吧没使用的戈全部输入空格，进入下一格"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "f807cb44",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\r",
      "world\n"
     ]
    }
   ],
   "source": [
    "print('hello\\rworld') # \\r return回车 world把hello覆盖了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "bb941cb9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\bworld\n"
     ]
    }
   ],
   "source": [
    "print('hello\\bworld') # \\退格 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "31843a73",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "http://www.baidu.com\n"
     ]
    }
   ],
   "source": [
    "print('http://www.baidu.com')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "c0ce0649",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "http:\\\\www.baidu.com\n"
     ]
    }
   ],
   "source": [
    "print(\"http:\\\\\\www.baidu.com\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "b7aa7123",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "http:\\\\www.baidu.com\n"
     ]
    }
   ],
   "source": [
    "print('http:\\\\\\\\www.baidu.com')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "39010e31",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (4097547291.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [17]\u001b[1;36m\u001b[0m\n\u001b[1;33m    print('老师说：'大家好'')\u001b[0m\n\u001b[1;37m                ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "print('老师说：'大家好'')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "ba2b2c3d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "老师说:'大家好'\n"
     ]
    }
   ],
   "source": [
    "print('老师说:\\'大家好\\'')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "1fd79eac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "老师说:\"大家好\"\n"
     ]
    }
   ],
   "source": [
    "print('老师说:\"大家好\"')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "fb9a496a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\\nworld\n"
     ]
    }
   ],
   "source": [
    "print(r'hello\\nworld') # 原字符，不希望字符串中的转义字符起作用，就用原字符，在字符串前加\"r\"或者\"R\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ecdf667",
   "metadata": {},
   "source": [
    "----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a792d6da",
   "metadata": {},
   "source": [
    "## python中的标识符和保留字"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "4fcb8ecd",
   "metadata": {},
   "outputs": [],
   "source": [
    "import keyword"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "06797f92",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "6f876297",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['False', 'None', 'True', '__peg_parser__', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']\n"
     ]
    }
   ],
   "source": [
    "print(keyword.kwlist) # python中的标识符（：变量、函数、类、模块和其他对象起的名字）和保留字  在给python文件或者python中的变量对象命名的时候不能使用的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0d82a6d8",
   "metadata": {},
   "source": [
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8084552a",
   "metadata": {},
   "source": [
    "## 变量的定义和使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "d9330659",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = '马冬梅' # name：变量名    =：赋值运算符       \"马冬梅\"：值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "a5068553",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "马冬梅\n"
     ]
    }
   ],
   "source": [
    "print(name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "dd732aef",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 变量由三部分组成\n",
    "# 1.标识：表示对象所存储的内存地址，使用内置函数id（obj）来获取\n",
    "# 2.类型：表示对象的数据类型，使用内置函数type（obj）来获取\n",
    "# 3.值：表示对象所储存的具体数据，使用print（obj）可以将值进行打印输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "67fd6fae",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = '马冬梅'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "5b68a959",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "马冬梅\n"
     ]
    }
   ],
   "source": [
    "print(name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "267682e5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "标识 2371142635760\n"
     ]
    }
   ],
   "source": [
    "print('标识',id(name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "d77a9820",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "类型 <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print('类型',type(name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "ff99d7ea",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "值 马冬梅\n"
     ]
    }
   ],
   "source": [
    "print('值',name)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "725985d6",
   "metadata": {},
   "source": [
    "## 数据类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "c6452a04",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 常用的数据类型\n",
    "# 整数类型→int\n",
    "# 浮点数类型→float\n",
    "# 布尔类型→bool→Ture False\n",
    "# 字符串类型→'人生苦短，我用pytho'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "03d2c840",
   "metadata": {},
   "source": [
    "### 整数类型  int→integer正数负数0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "bb3061c0",
   "metadata": {},
   "outputs": [],
   "source": [
    "n1 = 75"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "49aa5eff",
   "metadata": {},
   "outputs": [],
   "source": [
    "n2 = -34"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "b7243133",
   "metadata": {},
   "outputs": [],
   "source": [
    "n3 = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "a8092ff0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "75 -34 0\n"
     ]
    }
   ],
   "source": [
    "print(n1,n2,n3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "41e77b88",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "75 <class 'int'>\n"
     ]
    }
   ],
   "source": [
    "print(n1,type(n1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "762d677a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
